home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1999 Macromedia, Inc. All rights reserved.
-
- //******************* GLOBALS **********************
-
- var CMD_TO_LAUNCH = "Design Notes.htm";
-
- //***************** API ******************
-
- function canAcceptCommand() {
- var retVal = true; //always true for document window
-
- if (site.windowIsFrontmost()) { //if called for site window
- retVal = getSiteSelFile(); //true only if single-selection
- } else if (dw.getDocumentDOM() == null) retVal = false;
-
- return retVal;
- }
-
- //***************** LOCAL FUNCTIONS ******************
-
- function initializeUI() {
- var filePath = "", src, metafile;
-
- //ensure file is saved
-
- if (site.windowIsFrontmost()) { //if called for site window
- if (site.getFocus().toLowerCase() != "remote") { //local or map file selected
- src = getSiteSelFile();
- if (src) { //single selection
- var fObj = new File(src);
- if (fObj.canWrite()) {
- filePath = fObj.getAbsolutePath(); //resolve the local path of the selection
- } else {
- alert(MSG_ReadOnlyFile);
- }
- }
- } else {
- alert(MSG_RemoteFileSel);
- }
-
- } else { //called for doc window
- filePath = dreamweaver.getDocumentPath("document");
- if (!filePath) {
- if (confirm(MSG_WantSave) && dw.canSaveDocument(dreamweaver.getDocumentDOM('document'))) {
- dw.saveDocument(dreamweaver.getDocumentDOM('document'));
- filePath = dreamweaver.getDocumentPath("document");
- }
- } else { //file exists, ensure it's writeable
- var fObj = new File(filePath);
- if (!fObj.canWrite()) {
- filePath = ""; //clear, because we can't edit
- alert(MSG_ReadOnlyFile);
- }
- }
- }
-
- if (filePath) {
- metafile = (MMNotes.open(filePath)); //open, or create metafile
- if (metafile) { //if okay to open
- MMNotes.close(metafile); //close it
- MMNotes.FileInfo_filePath = filePath; //store the filePath as a global
- dreamweaver.popupCommand(CMD_TO_LAUNCH); //launch the command
- } else {
- alert(MSG_MetaDisabled);
- }
- }
- }
-
-
- function getSiteSelFile() {
- var fileList = site.getSelection();
- return ((fileList.length == 1)? fileList[0] : false);
- }
-